using NodeCanvas.Variables;
using UnityEngine;

namespace NodeCanvas.Actions
{
	[Name("Set Mecanim Float")]
	public class MecanimSetFloat : MecanimActions
	{
		[RequiredField]
		public string MecanimParameter;

		public BBFloat SetTo;

		[SliderField(0f, 1f)]
		public float TransitTime = 0.25f;

		private float currentValue;

		protected override string info
		{
			get
			{
				return "Mec.SetFloat '" + MecanimParameter + "' to " + SetTo.ToString();
			}
		}

		protected override void OnExecute()
		{
			currentValue = base.animator.GetFloat(MecanimParameter);
		}

		protected override void OnUpdate()
		{
			base.animator.SetFloat(MecanimParameter, Mathf.Lerp(currentValue, SetTo.value, base.elapsedTime / TransitTime));
			if (base.elapsedTime >= TransitTime)
			{
				EndAction(true);
			}
		}
	}
}
